from django.db.models import Q
from django.http import JsonResponse
from django.shortcuts import render
from apps.message.models import Messages_model
# Create your views here.
def msg_list(request):
    try:
        msg_list = Messages_model.objects.filter(Q(msg_deal_person_id=request.user.id)&Q(msg_is_read=1))
    except Exception:
        return JsonResponse({'code':201, 'msg':'消息查询失败！'})
    list1=[]
    for i in msg_list:
        dict1={}
        dict1['msg_receive_time'] = i.msg_receive_time
        dict1['msg_simple_text'] = i.msg_simple_text
        if i.msg_modular_from==2:
            dict1['msg_type']='业务消息！'
        list1.append(dict1)
    Result = {'code': 0, 'mes': '成功！', 'data': list1}
    return JsonResponse(Result)
